package com.bigdata.bookinfo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bigdata.bookinfo.pojo.KeyAndScore;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface MainDao extends BaseMapper {

    @Insert("insert into comment_dis values(#{range},#{number})")
    Integer insertCommentDis(String range,Integer number);

    @Insert("insert into book_years_num values(#{years},#{number})")
    Integer insertYeasNumber(String years,Integer number);

    @Insert("insert into comment_num values(#{title},#{number})")
    Integer insertCommentNum(String title,Integer number);

    @Insert("insert into book_author_num values(#{author},#{number})")
    Integer insertAuthorNum(String author,Integer number);

    @Insert("insert into book_press_num values(#{press},#{number})")
    Integer insertPressNum(String press,Integer number);

    @Insert("insert into price_r_dis values(#{range},#{number})")
    Integer insertPrice_rDis(String range,Integer number);

    @Insert("insert into keyword_dis values(#{keyword},#{number})")
    Integer insertKeywordDis(String keyword,Integer number);

    @ResultMap("commentNumMap")
    @Select("select * from comment_num")
    List<KeyAndScore> selectCommentNum();

    @ResultMap("commentDisMap")
    @Select("select * from comment_dis")
    List<KeyAndScore> selectCommentDis();

    @ResultMap("authorNumMap")
    @Select("select * from book_author_num order by number desc limit 0,10")
    List<KeyAndScore> selectAuthorNum();

    @ResultMap("pressNumMap")
    @Select("select * from book_press_num order by number desc limit 0,10")
    List<KeyAndScore> selectPressNum();

    @ResultMap("yearsNumMap")
    @Select("select * from book_years_num")
    List<KeyAndScore> selectYearsNum();

    @ResultMap("keywordNumMap")
    @Select("select * from keyword_dis order by number desc limit 0,30")
    List<KeyAndScore> selectKeywordNum();

    @ResultMap("priceDisMap")
    @Select("select * from price_r_dis")
    List<KeyAndScore> selectPriceDis();
}
